import { localUserInfo } from '@/utils';
import { get, post } from '@/utils/request';

const userIds = [localUserInfo()?.id];
// 公共接口
export const contractApi = (params: any = {}) => get(`/hdapi/gate/contract`, params); // 合约详情
export const tickersApi = (params = {}) => get(`/hdapi/gate/tickers`, params); // 合约交易行情
export const klineApi = (params = {}) => get(`/hdapi/gate/kline`, params); // k线图
export const orderBookApi = (params = {}) => get(`/hdapi/gate/orderBook`, params); // 市场深度信息
// export const contractListApi = (params = {}) => get(`${prefix}/futures/usdt/contracts`, params); // 合约列表
export const feiLvApi = (params = {}) => get(`/hdapi/gate/feiLv`, params); // 个人交易费率

// 我的接口
export const loginApi = (params = {}) => post('/hdapi/auth/login', params); // 登录
export const userDetailApi = (params: any = {}) => get(`/hdapi/user/detail`, params); // 用户详情
export const orderListApi = (params = {}) => get(`/hdapi/order/orderList`, { ...params, userIds }); // 订单(委托)列表
export const historyOrderApi = (params = {}) =>
  get(`/hdapi/order/historyOrder`, { ...params, userIds }); // 历史订单-旧
export const myHistoryOrderApi = (params = {}) =>
  get(`/hdapi/order/myHistoryOrder`, { ...params, userIds }); // 历史订单新

export const submitOrderApi = (params = {}) => post(`/hdapi/order/submitOrder`, params); // 下单
export const setLeverageApi = (params = {}) => post(`/hdapi/positions/setLeverage`, params); // 设置杠杆
export const contractAccount = (params = {}) => get(`/hdapi/user/futuresAccount`, params); // 合约账号
// 仓位列表
export const positionsApi = (params = {}) =>
  get(`/hdapi/positions/positions`, { ...params, userIds });
// 历史仓位
export const historyPositionApi = (params = {}) =>
  get(`/hdapi/positions/historyPositions`, { ...params, userIds });
export const delOrderApi = (params = {}) => get(`/hdapi/order/delOrder`, params); // 撤销
export const tradeListApi = (params = {}) => get(`/hdapi/order/myTrades`, { ...params, userIds }); // 成交记录
export const tradeListNewApi = (params = {}) =>
  get(`/hdapi/order/myTradesNew`, { ...params, userIds }); // 成交记录新
export const fundFlowApi = (params = {}) => get(`/hdapi/user/fundFlow`, { ...params, userIds }); // 资金流水
export const zhiYingSunApi = (params = {}) => post(`/hdapi/positions/zhiYingSun`, params); // 止盈止损
export const getZhiYingSunApi = (params = {}) => get(`/hdapi/positions/getZhiYingSun`, params); // 止盈止损列表
export const delZhiYingApi = (params = {}) => get(`/hdapi/positions/deleteZhiYingSun`, params); // 删除止盈
export const ziChanApi = (params = {}) => get(`/hdapi/user/ziChan`, { ...params, id: userIds[0] }); // 资产
export const zhiMaYingKuiApi = (params = {}) =>
  get(`/hdapi/user/zhiMaYingKui`, { ...params, id: userIds[0] }); // 芝麻盈亏

// 获取可用资产
export const keYongMoneyApi = (params = {}) =>
  get(`/hdapi/user/keYongMoney`, { ...params, id: userIds[0] });
// 定时同步芝麻的历史仓位
export const tongBuPositionsApi = (params = {}) =>
  get(`/hdapi/positions/tongBuHistoryPositions`, params);
// 历史仓位-我的
export const myHistoryPositionApi = (p = {}) =>
  get(`/hdapi/positions/myHistoryPosition`, { ...p, userIds });
